var Koa=require("koa");
var router=require("koa-router")();
var app=new Koa();
app.listen("3000",()=>{
    console.log("ok");
})
router.get("/",async ctx=>{
    ctx.cookies.set("user","123456");
    ctx.body=`<h1>cookies</h1><a href="/130">变迁</a>`
})
router.get("/130",async ctx=>{
    
    var count=ctx.cookies.get("count");
    if(count>0){
        count++
        ctx.cookies.set("count",count,{
            maxAge:2000
        });
        console.log(count)
    }
    else{
        count=1;
        console.log("456")
        ctx.cookies.set("count",count);
    }
    ctx.body=count;
})
app.use(router.routes());
